﻿layui.use(["colorpicker", "layer", "form", 'table'], function () {
    var layer = layui.layer,
        form = layui.form,
        colorpicker = layui.colorpicker,
        table = layui.table;
    var $ = layui.jquery;

    //弹出窗口
    layer.open({
        type: 1
        , title: "显示配置"
        , maxmin: true
        , content: $("#Menu")
        , area: '405px'
        , shade: 0
        , offset: [1, 1]
        , zIndex: layer.zIndex
        , resize: false
        , min: function (c) {
            $(".layui-layer-max").css("display", "inline-block")
        },
        restore: function (c) {
            $(".layui-layer-max").hide();
        },
        success: function (c, index) {
            $(".layui-layer-max").hide();
            $(".layui-layer-close").hide();
            setTimeout(function () {
                layer.min(index);
                $(".layui-layer-max").css("display", "inline-block")
            }, 500);
        },
    });

    //初始化玩家颜色选择器
    var playerColList = [
        ['#selfCol', '#00ff00'],
        ['#teamCol', '#00ff00'],
        ['#enemyCol', '#ff0000'],
        ['#fovCol', '#00ff00'],
        ['#robotCol', '#00bbff'],
        ['#visibleCol', '#000000']];

    for (var i = 0; i < playerColList.length; i++) {
        colorpicker.render({
            elem: playerColList[i][0] //绑定元素
            , color: playerColList[i][1]
            , size: 'xs'
            , done: function (color) {
                colName = this.elem.substr(1);
                if (colName == 'selfCol')
                    g_localPlayerCol = color;
                else if (colName == 'teamCol')
                    g_teamCol = color;
                else if (colName == 'enemyCol')
                    g_enemyCol = color;
                else if (colName == 'robotCol')
                    g_robotCol = color;
                else if (colName == 'fovCol')
                    g_fovCol = color;
                else if (colName == 'visibleCol')
                    g_visibleCol = color;
            }
        });
    }

    //监听玩家
    form.on('checkbox(Cbfilter)', function (data) {
        if (data.elem.title == '人物信息')
            g_bPlayerInfo = data.elem.checked;
        else if (data.elem.title == '地图跟随')
            g_bPlayerLock = data.elem.checked;
        else if (data.elem.title == '是否可见')
            g_bPlayerVisible = data.elem.checked;
        else if (data.elem.title == '朝向射线')
            g_bPlayerFov = data.elem.checked;
    });
});
